const fun1 = () => {
  return () => {
    console.log('fun1')
  }
}

const fun2 = () => {
  return () => {
    console.log('fun2')
  }
}

const fun3 = () => {
  return () => {
    console.log('fun3')
  }
}

const funcs = [fun1, fun2, fun3]

const result = funcs.reduce((a, b) => {
  console.log(a, b)
  return (...args) => {
    return a(b(...args))
  }
})

console.log('result', result, result()())
